#include "Render.h"

using namespace Gdiplus;

GraphicsPath* GdiHelper::CreateRoundRect(float x, float y, float width, float height, float radiusX, float radiusY)
{
	if(2 * radiusX > width ) radiusX = width / 2;
	if(2 * radiusY > height ) radiusY = height / 2;
	GraphicsPath* path = new GraphicsPath();
	float dx = radiusX * 2;
	float dy = radiusY * 2;
	path->AddArc(x, y, dx, dy, 180, 90);
	path->AddLine(radiusX, y, x + width - radiusX, y);
	path->AddArc(x + width - dx, y, dx, dy, 270, 90);
	path->AddLine(x + width, y + radiusY, x + width, y + height - radiusY);
	path->AddArc(x + width - dx, y + height - dy, dx, dy, 0, 90);
	path->AddLine(x + width - radiusX, y + height, x + radiusX, y + height);
	path->AddArc(x, y + height - dy, dx, dy, 90, 90);
	path->AddLine(x, y + height - radiusY, x, y + radiusY);
	path->CloseFigure();
	return path;
}